package com.biz.primus.ms.commodity.api;

import com.biz.primus.commodity.vo.SaleTagQueryVo;
import com.biz.primus.commodity.vo.backend.SaleTagListItemVo;
import com.biz.primus.commodity.vo.saleTag.SaleTagVo;
import com.biz.primus.common.vo.SpringPageVO;
import com.biz.primus.ms.base.api.BaseApiController;
import com.biz.primus.ms.commodity.service.backend.saleTag.SaleTagBackendService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * @author yanweijin
 * @date 2017/9/12
 */
@RestController
@RequestMapping("soa/saleTagService")
public class SaleTageApiController extends BaseApiController {


    private final SaleTagBackendService saleTagBackendService;

    public SaleTageApiController(SaleTagBackendService saleTagBackendService) {
        this.saleTagBackendService = saleTagBackendService;
    }

    @ApiOperation("创建或编辑标签")
    @PostMapping("updateSaleTag")
    void updateSaleTag(@RequestBody SaleTagVo saleTagVo) {
        saleTagBackendService.save(saleTagVo);
    }

    @ApiOperation("删除标签")
    @PostMapping("deleteSaleTag")
    void deleteSaleTag(@RequestParam("id") Long id) {
        saleTagBackendService.delete(id);
    }


    @ApiOperation("列出所有的标签")
    @PostMapping("findAll")
    SpringPageVO<SaleTagListItemVo> findAll(@RequestBody SaleTagQueryVo reqVo){
        return saleTagBackendService.findAll(reqVo);
    }

    @ApiOperation("通过SaleTagId获取SaleTag 基本信息")
    @GetMapping("getSaleTag")
    SaleTagVo getSaleTag(@RequestParam("id") Long saleTagId){
        return saleTagBackendService.findOne(saleTagId);
    }

}
